package com.solcoo.dao;

import java.sql.SQLException;
import javax.annotation.Resource;
import org.springframework.stereotype.Repository;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.solcoo.pojo.PriceTicket;

@Repository
public class PriceTicketDao {

	@Resource
	private SqlMapClient sqlMapClient;
	
    private static final String MODIFY_PRICE_TICKET = "modifyPriceTicket";
    private static final String INSERT_PRICE_TICKET = "insertPriceTicket";
    private static final String SELECT_PRICE_TICKET = "selectPriceTicket";

    public void modifyPriceTicket(PriceTicket pt) throws SQLException {
        int target = sqlMapClient.update(MODIFY_PRICE_TICKET, pt);
        if(target<1) {
            sqlMapClient.insert(INSERT_PRICE_TICKET, pt);
        }
    }

    public PriceTicket selectPriceTicket(int merchantId) throws SQLException {
        return (PriceTicket) sqlMapClient.queryForObject(SELECT_PRICE_TICKET, merchantId);
    }
}
